package com.zqh.shoppingcartquery.controller;

import com.zqh.myfmmall.result.Result;
import com.zqh.myfmmall.vo.ShoppingCartVO;
import com.zqh.shoppingcartquery.service.ShoppingCartQueryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description :
 * @Author :kono淇杭哒、
 * @Create 2022-02-18 2:15
 */
@RestController
@RequestMapping("shoppingCart")
public class ShoppingCartQueryController{
    @Resource
    private ShoppingCartQueryService shoppingCartQueryService;


    /**
     * 功能描述:
     * 提交订单服务等调用
     * @param
     * @return
     * @author kono曾淇杭哒！
     * @date 2022/3/5 23:38
     */
    @PostMapping("listByIds")
    public Result listByIds(@RequestBody List<String> ids){
        return Result.success(shoppingCartQueryService.listByIds(ids));
    }

    /**
     * 功能描述:
     * 前端选中购物车项生成订单时请求接口
     * @param
     * @return
     * @author kono曾淇杭哒！
     * @date 2022/3/5 23:39
     */
    @PostMapping("listVoByIds")
    public Result listVoByIds(@RequestBody List<String> ids){
        return Result.success(shoppingCartQueryService.getVosByIds(ids));
    }

    /**
     * 功能描述:
     *  前端请求用户购物车请求接口
     * @param
     * @return
     * @author kono曾淇杭哒！
     * @date 2022/3/5 23:40
     */
    @GetMapping("listVo")
    public Result listVoByUserId(@RequestParam("userId") String userId){
        List<ShoppingCartVO> shoppingCartVOS = shoppingCartQueryService.getVosByUserId(userId);
        return Result.success(shoppingCartVOS);
    }
}
